<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
<script src="../AngularJS/angular-1.5.0/angular.min.js"></script>
		<title></title>
	</head>
	<!--<body ng-app="myapp" ng-init= "i=['xxx','ccc']">-->
	<body ng-app="myapp" ng-init= "i='{a:a,b:b}'">
		<div ng-controller="myctrl">
			ctrl:
			<br/>
			<input type="text" ng-model="ctrlFlavor" />
			<button type="button"  ng-click=ff();>click</button>
			<br />
			directive:
			<br />
			<drink flavor="ctrlFlavor" ii="i" title="title"></drink>
<!--			<drink flavor="ctrlFlavor"></drink>-->
		</div>
<script>
	var app = angular.module("myapp",[]);
	app.controller("myctrl",function($scope){
		 $scope.ctrlFlavor="百威";
//		$scope.ctrlFlavor = ["aa","bb"];
		$scope.title = "青岛";
		$scope.ff = function (){
			$scope.ctrlFlavor = "xxx";
			console.log($scope.ctrlFlavor)
			console.log($scope.flavor)
		}

	});
	app.directive("drink",function(){
		return{
			restrict:"AE",
			scope:{
				flavor:"=",
				ii:"=",
				title:'='
			},
			template:'<input type="text" ng-model="flavor"><input type="text" ng-model="zz"><button type="button"  ng-click=ff2();>click22</button>',//
			link:function(scope){
				console.log(scope.flavor)
					console.log(JSON.stringify(scope.ii))
						console.log(scope.title)
				/*scope.$watch(scope.flavor,function(value){
//					newValue,oldValue, scope
				});*/
				/*scope.ff2 = function (){
				
					console.log(scope.ctrlFlavor)
					console.log(scope.flavor)
					console.log(f3())
				}
				
				function f3(){
					scope.zz = scope.flavor+"zzzzzzzzzzz";
				}
				*/
			},
			controller:function($scope,$http){
				/*console.log($scope.flavor.length)
				console.log(JSON.stringify($scope.ii))
				*/
			}
		}
	});
</script>
	</body>
</html>
